package com.lagou.rabbitmq.demo.controller;

import com.lagou.rabbitmq.demo.dao.Order;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.sql.SQLOutput;

@Controller
public class LagouPayController {
    @Autowired
    RabbitTemplate template;



    @RequestMapping("/pay/{orderId}")
    @ResponseBody
    public String payTheBill(@PathVariable String orderId, Model model){

        String result = "1";
        Object o = template.receiveAndConvert("queue.biz.topay");
        if (o != null){

            result = (String)o;
        }else{

            return "订单超时或者没有该订单";
        }
        System.out.println("订单" + result + "已支付");
        return "订单" + result + "已支付";

    }

}
